﻿using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp4
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        IContainerExtension _container;
        IRegionManager _regionManager;
        IRegion _region;
        ViewA _viewA;
        ViewB _viewB;
        ViewC _viewC;
        ViewD _viewD;
        public MainWindow(IContainerExtension container, IRegionManager regionManager)
        {
            InitializeComponent();
            _container = container;
            _regionManager = regionManager;

            this.Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            _viewA = _container.Resolve<ViewA>();//var viewA = new ViewA(); 
            _viewB = _container.Resolve<ViewB>();
            _viewC = _container.Resolve<ViewC>();
            _viewD = _container.Resolve <ViewD>();

            _region = _regionManager.Regions["ContentRegion"];

            _region.Add(_viewA);  
            _region.Add(_viewB);
            _region.Add(_viewC);
            _region.Add(_viewD);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _region.Activate(_viewA);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            _region.Activate(_viewB);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            _region.Activate(_viewC);
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            _region.Activate(_viewD);
        }
    }
}